package nongchang.kuaijiecaifu.com.ncapp_android.ui.fragment;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ezy.lite.util.ContextUtil;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.fragment.BaseFragment;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.BusinessDetailActivity;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.IntegralShopActivity;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.LifeShopActivity;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.MainActivity;
import nongchang.kuaijiecaifu.com.ncapp_android.util.ScaleUtil;


/**
 * Created by Administrator on 2016/3/12 0012.
 */
public class IconFragment extends BaseFragment {
    @BindView(R.id.txt__waimai)
    TextView txtWaimai;
    @BindView(R.id.txt_fuwudaojia)
    TextView txtFuwudaojia;
    @BindView(R.id.txt_bianjiegouwu)
    TextView txtBianjiegouwu;
    @BindView(R.id.txt_jifenshangcheng)
    TextView txtJifenshangcheng;
    @BindView(R.id.txt_youhuihuodong)
    TextView txtYouhuihuodong;
    @BindView(R.id.txt_shangjiaruzhu)
    TextView txtShangjiaruzhu;
    @BindView(R.id.txt_fenxianghaoyou)
    TextView txtFenxianghaoyou;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_icon, container, false);
        return view;
    }
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ButterKnife.bind(this, getView());
        int[] icon=new int[]{R.mipmap.waimai,R.mipmap.shangjiafuwu,R.mipmap.gouwu,R.mipmap.youhuiquan,R.mipmap.huodong,R.mipmap.jifenshangcheng,R.mipmap.bangdan};
        List<TextView> iconList= Arrays.asList(txtWaimai,txtFuwudaojia,txtBianjiegouwu,txtJifenshangcheng,txtYouhuihuodong,txtShangjiaruzhu,txtFenxianghaoyou);
        int iconDp= ScaleUtil.dip2px(getActivity(),40f);
        for(int i=0;i<iconList.size();i++){
            addImage(iconList.get(i),icon[i],iconDp);
        }
    }
    private void addImage(TextView textView,int drawableid,int dp){
        Drawable drawable=getResources().getDrawable(drawableid);
        drawable.setBounds(0,0,dp,dp);
        textView.setCompoundDrawables(null,drawable,null,null);
    }
    @OnClick({R.id.txt_jifenshangcheng,R.id.txt_bianjiegouwu,R.id.txt__waimai,R.id.txt_youhuihuodong,R.id.txt_fenxianghaoyou})
    void OnClick(View view){
        switch (view.getId()){
            case R.id.txt_jifenshangcheng:
                ContextUtil.startActivity(getContext(), IntegralShopActivity.class);
                break;
            case R.id.txt_bianjiegouwu:
                ContextUtil.startActivity(getContext(), LifeShopActivity.class);
                break;
            case R.id.txt__waimai:
//                ContextUtil.startActivity(getContext(), CartActivity.class);
                break;
            case R.id.txt_youhuihuodong:

                break;
            case R.id.txt_fenxianghaoyou:
                ContextUtil.startActivity(getContext(),BusinessDetailActivity.class);
                break;
        }
    }
}
